package com.metagurukul.metaspace.util;

/**
 * @author himanshu
 *
 */
public class PasswordGenerator {
	private String lowerCaseChar = "abcdefghijklmnopqrstuvwxyz";
	private String upperCaseChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	private String numeric = "1234567890";
	
	
	/**
	 * @return password of type String
	 */
	public String getPassword() {
		
		String password ="";
		password = password + generateRandom(upperCaseChar,26);
		password = password + generateRandom(numeric,10);
		password = password + generateRandom(lowerCaseChar,26);
		password = password + generateRandom(numeric,10);

		return password;
		
	}
	
	/**
	 * private method generate random password
	 */
	private  String generateRandom(String string,int length){
		String password = "";
		for (int i = 0; i < 2; i++) {
			int index = (int) (Math.random() * length);
			index = (index==length)?(length-1):index;
			password = password + string.charAt(index);
		}
		return password;
	}
	
	
}
